<template>
  <div>
    <h1>{{ product.name }}</h1>
    <p>{{ product.description }}</p>
    <p>价格: {{ product.price }}</p>
    <el-button @click="addToCart">加入购物车</el-button>
  </div>
</template>

<script>
import { getProductDetail } from '@/api/product';

export default {
  data() {
    return {
      product: {},
    };
  },
  methods: {
    async fetchProduct() {
      const response = await getProductDetail(this.$route.params.id);
      this.product = response.data;
    },
    async addToCart() {
      // 加入购物车逻辑
    },
  },
  mounted() {
    this.fetchProduct();
  },
};
</script>